package com.globallogic.vacationplanner.web.context;

import javax.faces.context.FacesContext;

public class BackinBeanContext {

	/**
	 * Returns JSF bean
	 * 
	 * @param beanName
	 *            the bean name
	 * @return the JSF bean if found
	 */
	@SuppressWarnings("unchecked")
	public <T> T findBean(String beanName) {
		FacesContext context = FacesContext.getCurrentInstance();
		return (T) context.getApplication().evaluateExpressionGet(context,
				"#{" + beanName + "}", Object.class);
	}
}
